local sk__fengying = fk.CreateSkill {

  name = "sk__fengying",

  tags = {  },

}



sk__fengying:addEffect(fk.BeforeDrawCard, {
  name = "sk__fengying",
  anim_type = "offensive",
  events = {fk.BeforeDrawCard},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__fengying.name) and player:usedSkillTimes(sk__fengying.name, Player.HistoryTurn) < 4
  end,
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    while data.num > 0 do
      if not player:hasSkill(sk__fengying.name) or self.cancel_cost or player:usedSkillTimes(sk__fengying.name, Player.HistoryTurn) > 3 then return end
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use=room:askToUseVirtualCard(player, {
      name = "thunder__slash",
      prompt = "#sk__fengying-invoke",
      skill_name = sk__fengying.name,
      cancelable = true,
      extra_data={
        bypass_times = true,
        bypass_distances = true,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, use)
      return true
    end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    data.num = data.num - 1
    player.room:useCard(event:getCostData(self))
  end,
})

return sk__fengying